import numpy as np
import cv2 as cv
H,S,V=0,0,0
s = 0
def callback_H(x):
   global H
   H = x
def callback_S(x):
   global S
   S = x
def callback_V(x):
    global V
    V = x
def callback_s(x):
    global s
    s = x

# Create a black image, a window
img =np.zeros((300,512,3),np.uint8)
winName ='image'
cv.namedWindow(winName)

tbName ='H'
tbInitValue =90
tbMaxValue=180
cv.createTrackbar(tbName,winName,tbInitValue,tbMaxValue,callback_H)
cv.createTrackbar('S',winName,255,255,callback_S)
cv.createTrackbar('V',winName,255,255,callback_V)
# create switch for ON/OFF functionalitys
switch ='OFF/ON'
cv.createTrackbar(switch,winName,0,1,callback_s)
while(1):
   cv.imshow(winName,img)
   k= cv.waitKey(1) & 0xFF
   if k == 27:
     break
   if s == 0:
     img[:]=0
   else:
     img[:]= [H,S,V]
     img[:]= cv.cvtColor(img, cv.COLOR_HSV2BGR)
cv.destroyAllWindows()